<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="css/jquery.min.js"></script>
</head>
<style>
    table{
        border-collapse: collapse;
        border: 1px solid black;
    }
    td{
        font-family: "楷体";
        text-align: center;
        font-size: 20px;
    }
</style>
<body>
    <button onclick="gogo()">发AJAX 请求</button>
    <div id="info"> </div>
    <table border="1" id="tab">

    </table>
</body>
<script>
    var path = "http://localhost:7070/json";
    function gogo() {
        $.ajax({
            url:path,
            dataType :"json",
            success:function (result) {
                console.log(result);
                show(result);
                // var ok = JSON.stringify(result);
                // $("#info").html(result);
                // for (i=0;i<result.length;i++) {
                //     $("#tab").append("<tr><td>"+result[i].stid+"</td><td>"+result[i].classid+"</td><td>"+result[i].stname+"</td><td>"+result[i].stpass+"</td></tr>");
                // }
            },
            error:function () {
                $("#info").html("请求失败");
            }
        });
    }

    function show(data) {
        var tb = document.querySelector("#tab");
        for(i=0;i<data.length;i++){
            var tr = tb.insertRow(); //新建一行
            var td = tr.insertCell();
            td.innerText = data[i].stid;
            var td = tr.insertCell();
            td.innerText = data[i].classid;
            var td = tr.insertCell();
            td.innerText = data[i].stname;
            var td = tr.insertCell();
            td.innerText = data[i].stpass;

        }
    }
</script>
</html>